var sqlMap = {
  user: {
    
    login: 'SELECT * FROM user WHERE username = ? and password = ? and level = ?',
    register: 'insert into user(username,password,name,answer,mail) values  (?,?,?,?,?)',
    queryUsername: 'select username from user where username = ?',
    userInfo: 'select * from user where id = ?',
    userPost: 'select * from post where postUserId = ?',
    userComment: 'select comment.id,postTitle,commTime,commContent,commPostId from comment,post where commUserId =? and post.id = commPostId',
    deletePost: 'delete from  post where id = ?',
    deleteComm: 'delete from  comment where id = ?',
    userInfoSave: 'update user set name =? , mail = ? where id= ? ',
    apply: 'insert into apply(forumName,forumContent,applyReason,applyTime,userId) values(?,?,?,?,?)',
    checkApply: 'select * from apply where userId	= ?',
  },
  main: {
    queryForum: 'select * from forum',
    queryPost: 'select post.id,postTitle,postContent,postTime,name from post,user where postForumId=? and post.postUserId = user.id and post.id not in (select id from stick where postForumId = ?)',
    sendPost: 'insert into post(postTitle,postContent,postTime,postUserId,postForumId) values (?,?,?,?,?)',
    post: 'select postTitle,postContent,postTime,username  from post,user where post.id=? and post.postUserId = user.id',
    comment: 'select comment.id,commContent,commTime,username from comment,user where commPostId = ? and commUserId = user.id',
    sendComment: 'insert into comment(commContent,commTime,commUserId,commPostId) values(?,?,?,?)'
  },
  moderator: {
    queryForum: 'select * from forum where forumUserId = ?',
    queryStick: 'select stick.id,postTitle,postContent,postTime,name from stick,user where postForumId=? and stick.postUserId = user.id ',
    deletePost: 'delete from post where id = ? ',
    stickPost: 'insert into stick (select * from post where id = ?)',
    deleteStick: 'insert into post (select * from stick where id = ?)',
    deleteStickThen: 'delete from stick where id = ?'
  },
  admin:{
  	queryAllUserP:'SELECT u.id,username,name,mail,level,COUNT(DISTINCT p.id) countPost from user u LEFT JOIN post p on u.id = p.postUserId group by u.username ORDER BY u.id',
  	queryAllUserC:'SELECT us.id,COUNT(DISTINCT c.id) countComment from user us LEFT JOIN `comment` c on us.id = c.commUserId group by us.username ORDER BY us.id',
  	deleteUser: 'delete from user where id= ?',
  	queryAllApply:'select apply.id,forumName,applyTime,forumContent,applyReason,username,status from apply,user where apply.userId = user.id order by status',
  	rejectApply: 'update  apply set status = 2 where id = ? ',
  	acceptApply: 'update  apply set status = 1 where id = ?' ,
  	queryAllForum:'select username,forum.id,forumName,forumContent,forumTime from forum,user where forum.forumUserId = user.id ',
  	deleteForum:'delete from forum where id=?',
  	queryInfo:'SELECT COUNT(DISTINCT forum.id) countForum,COUNT(DISTINCT post.id) countPost,COUNT(DISTINCT `comment`.id) countComment from forum,`comment`,post where forumTime >= ? and commTime >= ? and postTime >= ?'
  }
}
module.exports = sqlMap;